package com.example.tourism.controller;


import com.example.tourism.pojo.Result;
import com.example.tourism.pojo.po.HotelInfo;
import com.example.tourism.pojo.po.Img;
import com.example.tourism.pojo.po.Room;
import com.example.tourism.pojo.vo.res.HotelResVo;
import com.example.tourism.service.HotelService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hotel")
public class HotelController {
    // 商家入驻
    @Autowired
    private HotelService hotelService;

    @PostMapping(value = "/enterhotel")
    public Result addHotel(@RequestBody HotelInfo hotelInfo) {
        return hotelService.addHotel(hotelInfo);
    }

    @GetMapping("/getIsApplyHotel")
    public Result getIsApplyHotel(@RequestParam(value = "id") String id) {
        return hotelService.getIsApplyHotel(id);
    }

    @GetMapping("/fetchApplicationList")
    public Result fetchApplicationList(@RequestParam(value = "id") String id) {
        return hotelService.fetchApplicationList(id);
    }

    @PostMapping("/approveApplication")
    public Result approveApplication(@RequestParam(value = "id") String id) {
        return hotelService.approveApplication(id);
    }

    @PostMapping("/rejectApplication")
    public Result rejectApplication(@RequestParam(value = "id") String id) {
        return hotelService.rejectApplication(id);
    }

    @PostMapping("/withdrawApplication")
    public Result withdrawApplication(@RequestParam(value = "id") String id) {
        return hotelService.withdrawApplication(id);
    }

    @PostMapping("/insertNewRoom")
    public Result insertRoom(@RequestBody Room room,String id) {
        return hotelService.insertRoom(room,id);
    }

    @GetMapping("/getHotelRoomList")
    public Result getHotelRoomList(@RequestParam(value = "id") String id) {
        return hotelService.getHotelRoomList(id);
    }

    @GetMapping("/getRoomPhotos")
    public Result getRoomPhotos(@RequestParam(value = "id") String hotelId) {
        return hotelService.getRoomPhotos(hotelId);
    }

    @PostMapping("/updateRoomInfo")
    public Result updateRoomInfo(@RequestBody Room room) {
        return hotelService.updateRoomInfo(room);
    }

    @PostMapping("/uploadImg")
    public Result uploadImg(@RequestBody Img img,@RequestParam(value = "toId") String toId) {
        System.out.println("toId:"+toId);
        img.setToId(Integer.valueOf(toId));
        img.setType(0);
        return hotelService.uploadImg(img);
    }

    @GetMapping("/getHotelInfo")
    public Result getHotelInfo(@RequestParam(value = "id") String id) {
        return hotelService.getHotelInfo(id);
    }

    @PostMapping("/updateHotelInfo")
    public Result updateHotelInfo(@RequestBody HotelResVo hotelResVo) {
        return hotelService.updateHotelInfo(hotelResVo);
    }

    @GetMapping("/getHotelReviews")
    public Result getHotelReviews(@RequestParam(value = "id") String id) {
        return hotelService.getHotelReviews(id);
    }

    @GetMapping("/hotelGetComments")
    public  Result hotelGetComments(@RequestParam(value = "orderUid") String orderUid) {
        return hotelService.hotelGetComments(orderUid);
    }

    @PostMapping("/submitCommentReply")
    public Result submitCommentReply(String orderUid,String content ) {
        return hotelService.submitCommentReply(  orderUid,content);
    }
}
